package com.cloud.util.log.support;

import org.apache.log4j.Logger;

import com.cloud.util.log.support.Log;
import com.cloud.util.log.ALogFactory;
import com.cloud.util.log.ILog;
import com.cloud.util.log.ILogLeval;
import com.cloud.util.log.ILogMessage;

/**
 * 默认日志记录器，将日志内容输出到控制台
 * 
 * @version 0.1
 * @date 2012-09-01
 * @author DWZ框架组
 */
public class Log implements ILog {

	/* log4j日志组件 */
	private Logger fileLog = null;

	public Log() {

		fileLog = Logger.getLogger(Log.class);

	}

	public void info(String info) {

		info(ALogFactory.getLogMessage(info));

	}

	public void info(ILogMessage logMessage) {

		if (ILogLeval.D.equals(logMessage.getLogLeval())) {
			fileLog.debug(logMessage);
		} else if (ILogLeval.W.equals(logMessage.getLogLeval())) {
			fileLog.warn(logMessage);
		} else if (ILogLeval.E.equals(logMessage.getLogLeval())) {
			fileLog.warn(logMessage);
		} else {
			fileLog.info(logMessage);
		}

	}

	public void warn(Exception e) {
		
		fileLog.warn(e);

	}

	public void warn(String mess, Exception e) {

		mess = "W: "+mess;
		fileLog.warn(mess, e);

	}

}
